import sim, sim_items, main
from util import *
import random

class UnerringPrefix(sim_items.Prefix):
    """
   "darting" prefix increases a weapon's speed by reducing attack Energy"
    """
    def __init__(self):
        super(UnerringPrefix, self).__init__(
            "unerring", # name
            # description: (gets tacked onto item description)
            "Guided by an otherworldly magnetism for death, this weapon "
            "seems to know the blindspot's in your enemy's defense."
        )

    def initialize(self, wearable):
        if not isinstance(wearable, sim_items.Weapon):
            raise ValueError('Tried to apply %r to non-weapon item: %r' % (self,
                wearable))

        super(UnerringPrefix, self).initialize(wearable)

        self.hitBonus = random.randint(2,6) 
        self.wearable.bonuses.update({
        'hitMod': self.wearable.bonuses['hitMod'] + self.hitBonus,
        })

    def remove(self, wearable):
        super(UnerringPrefix, self).remove(wearable)
        wearable.bonuses.update({
            'hitMod': self.wearable.bonuses['hitMod'] - self.hitPenalty,
        })

#========================================
thingClass = UnerringPrefix

